package com.weixing.mall.provider.controller.rpc;

import com.weixing.mall.base.wrapper.Result;
import com.weixing.mall.base.wrapper.ResultUtil;
import com.weixing.mall.base.enums.IsEnableEnum;
import com.weixing.mall.core.support.BaseController;
import com.weixing.mall.provider.model.domain.PayChannel;
import com.weixing.mall.provider.api.model.vo.PaySetVo;
import com.weixing.mall.provider.service.IPayChannelService;
import com.weixing.mall.provider.service.IPaySetService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName PaySetRpcController
 * @Description
 * @Author Small
 * @Date 2020/2/17 11:46
 * @Version 1.0
 **/
@RestController
@RequestMapping("api/paySet")
public class PaySetRpcController extends BaseController {

    @Autowired
    private IPayChannelService payChannelService;
    @Autowired
    private IPaySetService paySetService;
    @GetMapping("loadPaySet")
    public Result loadPaySet(String channelCode){
        PayChannel payChannel = payChannelService.selectByCode(channelCode);
        if (null == payChannel || IsEnableEnum.DISABLE.getValue().intValue() == payChannel.getIsEnable()){
            return ResultUtil.error(payChannel.getChannelName() + "已禁用");
        }
        List<PaySetVo> paySetVos = paySetService.selectEnableListByChannelId(payChannel.getId());
        return ResultUtil.success(paySetVos);
    }
}
